<?php
$PaymentList = Dracosys::getSessionValue(SESSION_INTERFACE, 'PendingPaymentList');
$Cliente = Dracosys::getSessionValue(SESSION_INTERFACE, 'Customer');
?>
<h2>Lançar Pagamento</h2>
<section id="ReleasePayment">
    <header>
        <table class="TableInfo">
            <thead>
                <tr class="darkBlueGradient">
                    <th>NOME</th>
                    <th>EMAIL</th>
                    <th>DOCUMENTO</th>
                    <th>PLANO</th>
                </tr>
            </thead>
            <tbody>
                <tr class="lightblueGradient">
                    <td><?= $Cliente->getCustomerName() ?></td>
                    <td><?= $Cliente->getArGeneralData('StEmail') ?></td>
                    <td> <?= $Cliente->getDocument() ?></td>
                    <td> <?= $Cliente->getFinanceiro()->getPlano()->getStNome()?></td>
                </tr>
            </tbody>
        </table>
    </header>
    <?php
    if (!empty($PaymentList)):
        ?>
        <form method="post" action="financeiro/executar-lancamento" name="FormLancarPagamento">
            <?php
            foreach ($PaymentList as $Payment):
                ?>
                <div class="toggleContainer" id="ReleasePayment_togglePayment<?= $Payment->getIDDebito() ?>"><a href="#" class="toggle Up" rel="ReleasePayment_Payment<?= $Payment->getIDDebito() ?>">Pagamento correspondente ao periodo <span class="periodo"><?= $Payment->getPeriod() ?></span></a></div>
                <section id="ReleasePayment_Payment<?= $Payment->getIDDebito() ?>">
                    <div class="out_txt big"><label for="ReleasePayment_FoValor<?= $Payment->getIDDebito() ?>">Valor</label></div>
                    <div class="inp_txt big"><input type="text" name="FoValor" id="ReleasePayment_FoValor<?= $Payment->getIDDebito() ?>" value="<?= MathUtils::money($Payment->getFoValor()) ?>" class="price" /></div>
                    <div class="out_txt big"><label for="ReleasePayment_DtData<?= $Payment->getIDDebito() ?>">Data</label></div>
                    <div class="inp_txt big"><input type="text" name="DtData" id="ReleasePayment_DtData<?= $Payment->getIDDebito() ?>" value="<?= today() ?>" class="Date" /></div>
                    <div class="out_txt big"><label for="ReleasePayment_TipoPagamento<?= $Payment->getIDDebito() ?>">Data</label></div>
                    <div class="inp_txt big">
                        <select id="ReleasePayment_TipoPagamento<?= $Payment->getIDDebito() ?>" name="EnTipoPagamento">
                            <option value="CARTAO" <?= ($Payment->isCreditCard() ? 'selected="selected"' : '') ?>>CARTAO</option>
                            <option value="BOLETO" <?= ($Payment->isBill() ? 'selected="selected"' : '') ?>>BOLETO</option>
                        </select>
                    </div>
                </section>
                <?php
            endforeach;
            ?>
            <div class="btn"><button class="v1">Confirmar</button></div>
            <input type="hidden" name="IDFinanceiro" id="ReleasePayment_IDFinanceiro" value="<?= treatUrl('id') ?>" />
        </form>
        <?php
    else:
        ?>
        <div class="no-data">Este Cliente não possui nenhum Lançamento para realizar.</div>
    <?php
    endif;
    ?>
</section>